/*
 * Silicon Graphics, Inc.'s redbook android opengl es version
 * http://www.opengl.org/resources/code/samples/redbook/
 */

/*
 * Copyright (C) 2008 aki@akjava.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.akjava.android.openglsamples;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.akjava.android.openglsamples.redbook.AargbActivity;
import com.akjava.android.openglsamples.redbook.Alpha3DActivity;
import com.akjava.android.openglsamples.redbook.AlphaActivity;
import com.akjava.android.openglsamples.redbook.CheckerActivity;
import com.akjava.android.openglsamples.redbook.ClipActivity;
import com.akjava.android.openglsamples.redbook.ColorMatActivity;
import com.akjava.android.openglsamples.redbook.CubeActivity;
import com.akjava.android.openglsamples.redbook.FogActivity;
import com.akjava.android.openglsamples.redbook.LightActivity;
import com.akjava.android.openglsamples.redbook.MaterialActivity;
import com.akjava.android.openglsamples.redbook.MipmapActivity;
import com.akjava.android.openglsamples.redbook.ModelActivity;
import com.akjava.android.openglsamples.redbook.MoveLightActivity;
import com.akjava.android.openglsamples.redbook.PlanetActivity;
import com.akjava.android.openglsamples.redbook.RobotActivity;
import com.akjava.android.openglsamples.redbook.SceneActivity;
import com.akjava.android.openglsamples.redbook.SmoothActivity;
import com.akjava.android.openglsamples.redbook.StencilActivity;
import com.akjava.android.openglsamples.redbook.TeapotsActivity;
import com.akjava.android.openglsamples.redbook.TexbindActivity;
import com.akjava.android.openglsamples.redbook.TexsubActivity;
import com.akjava.android.openglsamples.redbook.WrapActivity;

public class RedBookSample extends ListActivity {
    /** Called when the activity is first created. */
	  @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setTitle("RedBook Sample");
	        
	        setListAdapter(new ArrayAdapter<String>(this,
	                android.R.layout.simple_list_item_1, listTitles()));
	        getListView().setTextFilterEnabled(true);
	    }

	    private Class[] actives={
	    		AargbActivity.class,
	    		Alpha3DActivity.class,
	    		AlphaActivity.class,
	    		CheckerActivity.class,
	    		ClipActivity.class,
	    		ColorMatActivity.class,
	    		CubeActivity.class,
	    		FogActivity.class,
	    		LightActivity.class,
	    		MaterialActivity.class,
	    		MipmapActivity.class,
	    		ModelActivity.class,
	    		MoveLightActivity.class,
	    		PlanetActivity.class,
	    		RobotActivity.class,
	    		SceneActivity.class,
	    		SmoothActivity.class,
	    		StencilActivity.class,
	    		TeapotsActivity.class,
	    		TexbindActivity.class,
	    		TexsubActivity.class,
	    		WrapActivity.class
	    };
	    public String[] listTitles(){
	    	String titles[]=new String[actives.length];
	    	for (int i = 0; i < titles.length; i++) {
	    		String t=actives[i].getSimpleName();
	    		t=t.substring(0,t.length()-"Activity".length());
				titles[i]=t;
			}
	    	return titles;
	    }
	    @Override
	    protected void onListItemClick(ListView l, View v, int position, long id) {
	        super.onListItemClick(l, v, position, id);
	        
	        
	        Intent i = null;
	 
	        //debug
	   	 i=new Intent(this,actives[position]);	
	        if(i!=null)
	        startActivity(i);
	    }
}